﻿using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Kronos.Classes;
using Kronos.DatabaseModels;
namespace Kronos.Webservices
{

    [WebService(Namespace = "http://tempuri.org")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class AutoCompleteCourse : System.Web.Services.WebService
    {

        [WebMethod]
        public string[] GetCourseList(String prefixText, Int32 count)
        {
          
            //start Database Constructor
           //soen341dBEntities dB = new soen341dBEntities();
          //  Entities dB = new Entities();
            soen341dBEntities1 dB = new soen341dBEntities1();
            
            List<string> classlist = new List<string>();
           
            foreach (Course_Object2 x in dB.Course_Object2)
                classlist.Add(x.course_code + " " + x.course_number);

            string[] ListCourses = classlist.ToArray();

         
            string[] TextboxDisplayedCourses = (from c in ListCourses
                                                where c.IndexOf(prefixText, StringComparison.OrdinalIgnoreCase) >= 0
                                                select c).Take<string>(count).ToArray();
            return TextboxDisplayedCourses;
            
        }
    }
}
